﻿using System;

namespace MockNetCore.Handlers
{
    public class StringHandler : TypeHandler
    {
        public object handle(Options options)
        {
            String sR = "";

            //  'foo': '★'
            if (options.rule.count == null)
            {
                sR += options.template;
            }
            else
            {
                // 'star|1-5': '★',
                for (int i = 0; i < options.rule.count; i++)
                {
                    sR += options.template;
                }
            }

            // 'email|1-10': '@EMAIL ,'
            options.template = sR;
            return PlaceholderHandler.doGenerate(options);
        }

        public Type[] support()
        {
            return new Type[] { typeof(string) };
        }
    }
}